#include<bits/stdc++.h>
#define F(i,x,y) for(int i=(x);i<=(y);i++)
#define DF(i,x,y) for(int i=(x);i>=(y);i--)
#define SZ(x) (int(x.size())-1)
#define mid ((l+r)>>1)
#define all(x) x.begin(),x.end()
#define pb push_back
using namespace std;
bool chkmax(int &x,int y){return (x<y?x=y:0);}
bool chkmin(int &x,int y){return (x>y?x=y:0);}
bool chkmax(double &x,double y){return (x<y?x=y:0);}
bool chkmin(double &x,double y){return (x>y?x=y:0);}
int n,m,L,V;
struct Car{
    int d,v,a,l,r;
    bool operator < (const Car &t) const {
        return r<t.r;
    }
};
vector<Car>car,tmp;
int pf(int x)
{
    return x*x;
}
int p[100010],dp[100010];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    while(T--)
    {
        cin>>n>>m>>L>>V;
        F(i,1,m)dp[i]=0x3f3f3f3f;
        int s=0;
        double mostl=0;
        tmp.clear();
        car.clear();
        F(i,1,n)
        {
            int d,v,a;
            scanf("%d%d%d",&d,&v,&a);
            Car Tmp;
            Tmp.d=d;
            Tmp.v=v;
            Tmp.a=a;
            tmp.pb(Tmp);
        }
        F(i,1,m)cin>>p[i];
        int mostrl=0;
        F(i,0,n-1)
        {
			if(tmp[i].d>p[m])continue;
            if(tmp[i].a==0)
            {
                if(tmp[i].v>V)
                {
                    s++;
                    chkmax(mostl,tmp[i].d);
                }
            }
            else if(tmp[i].a>0)
            {
            
                if(tmp[i].v>V)
                {
                    s++;
                    chkmax(mostl,tmp[i].d);
                }
                else if((pf(V)-pf(tmp[i].v))<(p[m]-tmp[i].d)*2*tmp[i].a)
                {
					s++;
                    chkmax(mostl,ceil((pf(V)-pf(tmp[i].v))/(2.0*tmp[i].a))+tmp[i].d);
                }
            }
            else if(tmp[i].v>V&&tmp[i].d<=p[m])
            {
                int tp=lower_bound(p,p+m+1,tmp[i].d)-p;
                if(pf(tmp[i].v)+2*tmp[i].a*(p[tp]-tmp[i].d)>pf(V))
                {
                    s++;
                    tmp[i].l=tp;
                    if(pf(tmp[i].v)+2*tmp[i].a*(p[m]-tmp[i].d)>pf(V))
                        tmp[i].r=m;
                    else
                        tmp[i].r=lower_bound(p+tp,p+m+1,tmp[i].d-(pf(tmp[i].v)-pf(V))/(2.0*tmp[i].a))-p-1;
                    chkmax(mostrl,tmp[i].l);
                    car.pb(tmp[i]);
                }
            }
        }
        if(!s)
        {
			cout<<0<<' '<<m<<endl;
			continue;
        }
        int mli=0;
        if(mostl>0)
        {
			F(i,1,m)
			{
				if(p[i]>=mostl)
				{
					mli=i;
					break;
				}
			}
		}
        sort(all(car));
        dp[0]=0;
        int mostr=0,mri=-1;
        F(i,1,m)
        {
            while(mri<SZ(car)&&car[mri+1].r<i)
            {
                mri++;
                chkmax(mostr,car[mri].l);
            }
            dp[i]=dp[mostr]+1;
        }
        int ans=dp[mostrl];
        if(mostrl<mli)ans++;
        chkmin(ans,dp[max(mostrl,mli)]);
        cout<<s<<' '<<m-ans<<endl;
    }
    return 0;
}
//woyaodaqiu!!!
